package KeyHelper

import (
	"awesomeTask/commom/StringHelper"
	"net"
	"strconv"
	"strings"
)

func TcpUniqueId(ip string, port int) string {
	return ip + ":" + strconv.Itoa(port)
}
func TcpUniqueIdByConnection(conn net.Conn) string {
	ip, port := GetIpAndPort(conn)
	return TcpUniqueId(ip, port)
}
func GetIpAndPort(conn net.Conn) (string, int) {
	ipstring := strings.Split(conn.RemoteAddr().String(), ":")
	return ipstring[0], StringHelper.ParseInt(ipstring[1])
}
